package com.java.wmovie.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器
 */
@Configuration
public class SecurityConfiguration implements WebMvcConfigurer {
    @Autowired
    UserInterceptor userInterceptor;
    @Autowired
    AdminInterceptor adminInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userInterceptor)
                .addPathPatterns("/movie/buy")
                .addPathPatterns("/movie/buy1")
                .addPathPatterns("/movie/buys")
                .addPathPatterns("/movie/buy2")
                .addPathPatterns("/user/**")
        ;
        registry.addInterceptor(adminInterceptor)
                .addPathPatterns("/admin/**");
    }
}
